package com.wd.elec.controller.bussiness;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.wd.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wd.common.core.controller.BaseController;
import com.wd.common.core.domain.HttpResponse;
import com.wd.common.annotation.Log;
import com.wd.common.enums.BusinessType;
import com.wd.elec.domain.AttendSchedule;
import com.wd.elec.service.IAttendScheduleService;


/**
 * 考勤班次Controller
 * 
 * @author liumingkun
 * @date 2023-11-07
 */
@RestController
@RequestMapping("/attend/schedule")
public class AttendScheduleController extends BaseController
{
    @Resource
    private IAttendScheduleService attendScheduleService;

    /**
     * 查询考勤班次列表
     */
    @PreAuthorize("@ss.hasPermi('attend:schedule:list')")
    @GetMapping("/list")
    public HttpResponse list(AttendSchedule attendSchedule)
    {
        startPage();
        List<AttendSchedule> list = attendScheduleService.selectAttendScheduleList(attendSchedule);
        return HttpResponse.successData(getDataTable(list));
    }

    /**
     * 导出考勤班次列表
     */
    @PreAuthorize("@ss.hasPermi('attend:schedule:export')")
    @Log(title = "考勤班次", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AttendSchedule attendSchedule)
    {
        List<AttendSchedule> list = attendScheduleService.selectAttendScheduleList(attendSchedule);
        ExcelUtil<AttendSchedule> util = new ExcelUtil<AttendSchedule>(AttendSchedule.class);
        util.exportExcel(response, list, "考勤班次数据");
    }

    /**
     * 获取考勤班次详细信息
     */
    @PreAuthorize("@ss.hasPermi('attend:schedule:query')")
    @GetMapping(value = "/{scheduleId}")
    public HttpResponse getInfo(@PathVariable("scheduleId") Long scheduleId)
    {
        return successData(attendScheduleService.selectAttendScheduleByScheduleId(scheduleId));
    }

    /**
     * 新增考勤班次
     */
    @PreAuthorize("@ss.hasPermi('attend:schedule:add')")
    @Log(title = "考勤班次", businessType = BusinessType.INSERT)
    @PostMapping
    public HttpResponse add(@RequestBody AttendSchedule attendSchedule)
    {
        return getResult(attendScheduleService.insertAttendSchedule(attendSchedule));
    }

    /**
     * 修改考勤班次
     */
    @PreAuthorize("@ss.hasPermi('attend:schedule:edit')")
    @Log(title = "考勤班次", businessType = BusinessType.UPDATE)
    @PutMapping
    public HttpResponse edit(@RequestBody AttendSchedule attendSchedule)
    {
        return getResult(attendScheduleService.updateAttendSchedule(attendSchedule));
    }

    /**
     * 删除考勤班次
     */
    @PreAuthorize("@ss.hasPermi('attend:schedule:remove')")
    @Log(title = "考勤班次", businessType = BusinessType.DELETE)
	@DeleteMapping("/{scheduleIds}")
    public HttpResponse remove(@PathVariable Long[] scheduleIds)
    {
        return getResult(attendScheduleService.deleteAttendScheduleByScheduleIds(scheduleIds));
    }
}
